Coverage Report

Created: 2024-12-19 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
D:\a\tools.proto\tools.proto\compiler\src\gen\rust\params.rs
Line
Count
Source
1
// Copyright (c) 2024, BlockProject 3D
2
//
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without modification,
6
// are permitted provided that the following conditions are met:
7
//
8
//     * Redistributions of source code must retain the above copyright notice,
9
//       this list of conditions and the following disclaimer.
10
//     * Redistributions in binary form must reproduce the above copyright notice,
11
//       this list of conditions and the following disclaimer in the documentation
12
//       and/or other materials provided with the distribution.
13
//     * Neither the name of BlockProject 3D nor the names of its contributors
14
//       may be used to endorse or promote products derived from this software
15
//       without specific prior written permission.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
use std::collections::HashSet;
30
31
#[derive(Default, Debug)]
32
pub struct Params<'a> {
33
    pub(crate) enable_struct_to_mut: bool,
34
    pub(crate) enable_struct_dupe: HashSet<&'a str>,
35
    pub(crate) enable_write_async: bool,
36
    pub(crate) enable_union_set_discriminant: bool,
37
    pub(crate) enable_list_wrappers: bool,
38
    pub(crate) enable_message_offsets: bool,
39
    pub(crate) disable_read: HashSet<&'a str>,
40
    pub(crate) disable_write: HashSet<&'a str>,
41
}
42
43
impl<'a> Params<'a> {
44
9
    pub fn enable_struct_to_mut(mut self, flag: bool) -> Self {
45
9
        self.enable_struct_to_mut = flag;
46
9
        self
47
9
    }
48
49
1
    pub fn enable_struct_dupe(mut self, name: &'a str) -> Self {
50
1
        self.enable_struct_dupe.insert(name);
51
1
        self
52
1
    }
53
54
9
    pub fn enable_union_set_discriminant(mut self, flag: bool) -> Self {
55
9
        self.enable_union_set_discriminant = flag;
56
9
        self
57
9
    }
58
59
9
    pub fn enable_list_wrappers(mut self, flag: bool) -> Self {
60
9
        self.enable_list_wrappers = flag;
61
9
        self
62
9
    }
63
64
9
    pub fn enable_message_offsets(mut self, flag: bool) -> Self {
65
9
        self.enable_message_offsets = flag;
66
9
        self
67
9
    }
68
69
9
    pub fn enable_write_async(mut self, flag: bool) -> Self {
70
9
        self.enable_write_async = flag;
71
9
        self
72
9
    }
73
74
0
    pub fn disable_read(mut self, name: &'a str) -> Self {
75
0
        self.disable_read.insert(name);
76
0
        self
77
0
    }
78
79
0
    pub fn disable_write(mut self, name: &'a str) -> Self {
80
0
        self.disable_write.insert(name);
81
0
        self
82
0
    }
83
}